package cn.serein.charging.cost.controller;


import cn.serein.charging.common.pojo.JsonResult;
import cn.serein.charging.common.pojo.param.ChargingProcessParam;
import cn.serein.charging.common.pojo.vo.ChargingProcessVO;
import cn.serein.charging.cost.service.CostService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
@RequestMapping("cost")
@Api(tags = "计算服务")
public class CostController {

    @Autowired
    private CostService costService;

    /**
     * 分析业务   需要返回出参   gunId
     * @param chargingProcessParam
     * @return
     */

    @ApiOperation(value = "计算费用")
    @PostMapping("calculate")
    public JsonResult calculateCost(@RequestBody ChargingProcessParam chargingProcessParam){
        log.debug("计算费用入参：{}",chargingProcessParam);
        ChargingProcessVO chargingProcessVO = costService.calculateCost(chargingProcessParam);
        // 提供个调用者
        log.debug("计算费用出参：{}",chargingProcessVO);

        return JsonResult.success(200,"计算费用成功",chargingProcessVO);
    }
}
